<!doctype html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/blog/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="redis,redis集群," />








  <link rel="shortcut icon" type="image/x-icon" href="/blog/favicon.ico?v=5.1.0" />






<meta name="description" content="redis主从复制可以避免redis的单点故障，实现容灾高可用；同时也可以实现读写分离，提高系统吞吐量实现高负载。    但是redis主从复制的模式存在缺点就是：    1、如果主从模式下的reids服务故障宕机，则redis无法通知客户端，需要客户端手动更改配置重新连接。    2、主从模式下，master节点宕机，则从节点因为没有主节点而中断同步，需要人工进行故障转移。（先将slave节点从">
<meta name="keywords" content="redis,redis集群">
<meta property="og:type" content="article">
<meta property="og:title" content="redis哨兵模式搭建">
<meta property="og:url" content="https://gitee.com/shuhao/2017/12/18/redis哨兵模式搭建/index.html">
<meta property="og:site_name" content="Niki">
<meta property="og:description" content="redis主从复制可以避免redis的单点故障，实现容灾高可用；同时也可以实现读写分离，提高系统吞吐量实现高负载。    但是redis主从复制的模式存在缺点就是：    1、如果主从模式下的reids服务故障宕机，则redis无法通知客户端，需要客户端手动更改配置重新连接。    2、主从模式下，master节点宕机，则从节点因为没有主节点而中断同步，需要人工进行故障转移。（先将slave节点从">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://gitee.com/blog/images/redis/sentinel.jpg">
<meta property="og:updated_time" content="2017-12-23T01:54:37.698Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="redis哨兵模式搭建">
<meta name="twitter:description" content="redis主从复制可以避免redis的单点故障，实现容灾高可用；同时也可以实现读写分离，提高系统吞吐量实现高负载。    但是redis主从复制的模式存在缺点就是：    1、如果主从模式下的reids服务故障宕机，则redis无法通知客户端，需要客户端手动更改配置重新连接。    2、主从模式下，master节点宕机，则从节点因为没有主节点而中断同步，需要人工进行故障转移。（先将slave节点从">
<meta name="twitter:image" content="https://gitee.com/blog/images/redis/sentinel.jpg">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/blog/',
    scheme: 'Mist',
    sidebar: {"position":"right","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://gitee.com/shuhao/2017/12/18/redis哨兵模式搭建/"/>





  <title> redis哨兵模式搭建 | Niki </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?cb9f0585e406f878cb2f29c89ad3cdb7";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>










  
  
    
  

  <div class="container one-collumn sidebar-position-right page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Niki</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">天道酬勤</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/blog/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-categories"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/blog/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="https://gitee.com/shuhao/blog/2017/12/18/redis哨兵模式搭建/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Fang ShuHao">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/head.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Niki">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                redis哨兵模式搭建
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-12-18T09:30:50+08:00">
                2017-12-18
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/redis/" itemprop="url" rel="index">
                    <span itemprop="name">redis</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>redis主从复制可以避免redis的单点故障，实现容灾高可用；同时也可以实现读写分离，提高系统吞吐量实现高负载。<br>    但是redis主从复制的模式存在缺点就是：<br>    1、如果主从模式下的reids服务故障宕机，则redis无法通知客户端，需要客户端手动更改配置重新连接。<br>    2、主从模式下，master节点宕机，则从节点因为没有主节点而中断同步，需要人工进行故障转移。（先将slave节点从主从模式下断开，重启master节点，然后再次将slave节点连上master节点。）无法做到故障切换。</p>
<p>为了解决redis主从模式的这些缺点，redis推出了新的集群方案<em>sentinel哨兵模式</em></p>
<img src="/blog/images/redis/sentinel.jpg">
<h2 id="sentinel-哨兵模式的搭建"><a href="#sentinel-哨兵模式的搭建" class="headerlink" title="sentinel 哨兵模式的搭建"></a>sentinel 哨兵模式的搭建</h2><h3 id="1、安装redis"><a href="#1、安装redis" class="headerlink" title="1、安装redis"></a>1、安装redis</h3><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">cd /usr/local/redis</span><br><span class="line"></span><br><span class="line">$ wget http://download.redis.io/releases/redis-4.0.6.tar.gz</span><br><span class="line">$ tar xzf redis-4.0.6.tar.gz</span><br><span class="line">$ cd redis-4.0.6</span><br><span class="line">$ make</span><br></pre></td></tr></table></figure>
<h3 id="2、新建目录"><a href="#2、新建目录" class="headerlink" title="2、新建目录"></a>2、新建目录</h3><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">cd /usr/local/redis</span><br><span class="line">mkdir -p redis-sentinel/master redis-sentinel/slave_1 redis-sentinel/slave_2 redis-sentinel/slave_3</span><br><span class="line">mkdir -p redis-sentinel/master/data redis-sentinel/slave_1/data redis-sentinel/slave_2/data  redis-sentinel/slave_3/data</span><br><span class="line">mkdir -p redis-sentinel/master/log redis-sentinel/slave_1/log redis-sentinel/slave_2/log  redis-sentinel/slave_3/log</span><br><span class="line"></span><br><span class="line">mkdir -p redis-sentinel/master/log redis-sentinel/sentinel_1/log redis-sentinel/sentinel_2/log</span><br></pre></td></tr></table></figure>
<h3 id="3、配置"><a href="#3、配置" class="headerlink" title="3、配置"></a>3、配置</h3><h3 id="复制配置文件到服务节点以及哨兵节点"><a href="#复制配置文件到服务节点以及哨兵节点" class="headerlink" title="复制配置文件到服务节点以及哨兵节点"></a>复制配置文件到服务节点以及哨兵节点</h3><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">cp /usr/local/redis/redis-4.0.6/redis.conf /usr/local/redis/redis-sentinel/master</span><br><span class="line">cp /usr/local/redis/redis-4.0.6/redis.conf /usr/local/redis/redis-sentinel/slave_1</span><br><span class="line">cp /usr/local/redis/redis-4.0.6/redis.conf /usr/local/redis/redis-sentinel/slave_2</span><br><span class="line">cp /usr/local/redis/redis-4.0.6/redis.conf /usr/local/redis/redis-sentinel/slave_3</span><br><span class="line"></span><br><span class="line">cp /usr/local/redis/redis-4.0.6/sentinel.conf /usr/local/redis/redis-sentinel/sentinel_1</span><br><span class="line">cp /usr/local/redis/redis-4.0.6/sentinel.conf /usr/local/redis/redis-sentinel/sentinel_2</span><br></pre></td></tr></table></figure>
<h3 id="修改master目录-redis-conf"><a href="#修改master目录-redis-conf" class="headerlink" title="修改master目录 redis.conf"></a>修改master目录 redis.conf</h3><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">#master</span><br><span class="line">logfile /usr/local/redis/redis-sentinel/master/log/log.log</span><br><span class="line">dir /usr/local/redis/redis-sentinel/master/data</span><br><span class="line">bind 127.0.0.1</span><br><span class="line">port 6666</span><br><span class="line">#服务以守护进程的方式在后台运行</span><br><span class="line">daemonize yes</span><br><span class="line">pidfile  /usr/local/redis/redis-sentinel/master/redis_6666.pid</span><br></pre></td></tr></table></figure>
<h3 id="修改slave-1目录-redis-conf"><a href="#修改slave-1目录-redis-conf" class="headerlink" title="修改slave_1目录 redis.conf"></a>修改slave_1目录 redis.conf</h3><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">#slave1</span><br><span class="line">logfile /usr/local/redis/redis-sentinel/slave_1/log/log.log</span><br><span class="line">dir /usr/local/redis/redis-sentinel/slave_1/data</span><br><span class="line">bind 127.0.0.1</span><br><span class="line">port 6667</span><br><span class="line">slaveof 127.0.0.1 6666</span><br><span class="line">#服务以守护进程的方式在后台运行</span><br><span class="line">daemonize yes</span><br><span class="line">pidfile  /usr/local/redis/redis-sentinel/slave_1/redis_6667.pid</span><br></pre></td></tr></table></figure>
<h3 id="修改slave-2目录-redis-conf"><a href="#修改slave-2目录-redis-conf" class="headerlink" title="修改slave_2目录 redis.conf"></a>修改slave_2目录 redis.conf</h3><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">#slave2</span><br><span class="line">logfile /usr/local/redis/redis-sentinel/slave_2/log/log.log</span><br><span class="line">dir /usr/local/redis/redis-sentinel/slave_2/data</span><br><span class="line">bind 127.0.0.1</span><br><span class="line">port 6668</span><br><span class="line">slaveof 127.0.0.1 6666</span><br><span class="line">daemonize yes</span><br><span class="line">pidfile  /usr/local/redis/redis-sentinel/slave_2/redis_6668.pid</span><br></pre></td></tr></table></figure>
<h3 id="修改slave-3目录-redis-conf"><a href="#修改slave-3目录-redis-conf" class="headerlink" title="修改slave_3目录 redis.conf"></a>修改slave_3目录 redis.conf</h3><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">#slave3</span><br><span class="line">logfile /usr/local/redis/redis-sentinel/slave_3/log/log.log</span><br><span class="line">dir /usr/local/redis/redis-sentinel/slave_3/data</span><br><span class="line">bind 127.0.0.1</span><br><span class="line">port 6669</span><br><span class="line">slaveof 127.0.0.1 6666</span><br><span class="line">daemonize yes</span><br><span class="line">pidfile  /usr/local/redis/redis-sentinel/slave_3/redis_6669.pid</span><br></pre></td></tr></table></figure>
<h3 id="修改sentinel-1目录sentinel-conf"><a href="#修改sentinel-1目录sentinel-conf" class="headerlink" title="修改sentinel_1目录sentinel.conf"></a>修改sentinel_1目录sentinel.conf</h3><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">daemonize yes</span><br><span class="line">port 6670</span><br><span class="line">sentinel monitor mymaster 127.0.0.1 6666 2</span><br></pre></td></tr></table></figure>
<h3 id="修改sentinel-2目录sentinel-conf"><a href="#修改sentinel-2目录sentinel-conf" class="headerlink" title="修改sentinel_2目录sentinel.conf"></a>修改sentinel_2目录sentinel.conf</h3><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">daemonize yes</span><br><span class="line">port 6671</span><br><span class="line">sentinel monitor mymaster 127.0.0.1 6666 2</span><br></pre></td></tr></table></figure>
<h3 id="4、启动"><a href="#4、启动" class="headerlink" title="4、启动"></a>4、启动</h3><p>首先启动master节点，然后启动slave节点<br><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">/usr/local/redis/redis-4.0.6/src/redis-server /usr/local/redis/redis-sentinel/master/redis.conf</span><br><span class="line">/usr/local/redis/redis-4.0.6/src/redis-server /usr/local/redis/redis-sentinel/slave_1/redis.conf</span><br><span class="line">/usr/local/redis/redis-4.0.6/src/redis-server /usr/local/redis/redis-sentinel/slave_2/redis.conf</span><br><span class="line">/usr/local/redis/redis-4.0.6/src/redis-server /usr/local/redis/redis-sentinel/slave_3/redis.conf</span><br><span class="line"></span><br><span class="line">/usr/local/redis/redis-4.0.6/src/redis-sentinel /usr/local/redis/redis-sentinel/sentinel_1/sentinel.conf</span><br><span class="line">/usr/local/redis/redis-4.0.6/src/redis-sentinel /usr/local/redis/redis-sentinel/sentinel_2/sentinel.conf</span><br></pre></td></tr></table></figure></p>
<p>启动各个节点的客户端<br><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">/usr/local/redis/redis-4.0.6/src/redis-cli -h 127.0.0.1 -p 6666</span><br><span class="line">/usr/local/redis/redis-4.0.6/src/redis-cli -h 127.0.0.1 -p 6667</span><br><span class="line">/usr/local/redis/redis-4.0.6/src/redis-cli -h 127.0.0.1 -p 6668</span><br><span class="line">/usr/local/redis/redis-4.0.6/src/redis-cli -h 127.0.0.1 -p 6669</span><br><span class="line"></span><br><span class="line">/usr/local/redis/redis-4.0.6/src/redis-cli -h 127.0.0.1 -p 6670</span><br><span class="line">/usr/local/redis/redis-4.0.6/src/redis-cli -h 127.0.0.1 -p 6671</span><br></pre></td></tr></table></figure></p>
<h3 id="关于sentinel模式的几个命令"><a href="#关于sentinel模式的几个命令" class="headerlink" title="关于sentinel模式的几个命令"></a>关于sentinel模式的几个命令</h3><p>在sentinel节点可以通过以下命令查看哨兵模式的状态<br><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">#查看sentinel基本信息</span><br><span class="line">info</span><br><span class="line"></span><br><span class="line">#列出被监视的master节点当前状态</span><br><span class="line">sentinel masters</span><br><span class="line"></span><br><span class="line">#列出被监视的slave节点的状态</span><br><span class="line">sentinel slaves mymaster</span><br><span class="line"></span><br><span class="line">#当主服务器失效时， 在不询问其他 Sentinel 意见的情况下， 强制开始一次自动故障迁移，但是它会给其他sentinel发送一个最新的配置，其他sentinel会根据这个配置进行更新</span><br><span class="line">sentinel failover mymaster</span><br></pre></td></tr></table></figure></p>
<h2 id="验证哨兵模式功能"><a href="#验证哨兵模式功能" class="headerlink" title="验证哨兵模式功能"></a>验证哨兵模式功能</h2><p>按照上面的操作步骤，我们的sentinel模式也创建成功了，那么我们来验证sentinel模式给我们解决master-slave模式的问题。</p>
<h3 id="1、主从复制"><a href="#1、主从复制" class="headerlink" title="1、主从复制"></a>1、主从复制</h3><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">127.0.0.1:6666&gt; role</span><br><span class="line">1) &quot;master&quot;</span><br><span class="line">2) (integer) 5777903</span><br><span class="line">3) 1) 1) &quot;127.0.0.1&quot;</span><br><span class="line">      2) &quot;6667&quot;</span><br><span class="line">      3) &quot;5777903&quot;</span><br><span class="line">   2) 1) &quot;127.0.0.1&quot;</span><br><span class="line">      2) &quot;6668&quot;</span><br><span class="line">      3) &quot;5777771&quot;</span><br><span class="line">   3) 1) &quot;127.0.0.1&quot;</span><br><span class="line">      2) &quot;6669&quot;</span><br><span class="line">      3) &quot;5777771&quot;</span><br><span class="line">127.0.0.1:6666&gt; set say &quot;Hello Redis&quot;</span><br><span class="line">OK</span><br><span class="line">127.0.0.1:6666&gt;</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">127.0.0.1:6667&gt; role</span><br><span class="line">1) &quot;slave&quot;</span><br><span class="line">2) &quot;127.0.0.1&quot;</span><br><span class="line">3) (integer) 6666</span><br><span class="line">4) &quot;connected&quot;</span><br><span class="line">5) (integer) 5793819</span><br><span class="line">127.0.0.1:6667&gt; set fruit apple</span><br><span class="line">(error) READONLY You can&apos;t write against a read only slave.</span><br><span class="line">127.0.0.1:6667&gt; get say</span><br><span class="line">&quot;Hello Redis&quot;</span><br><span class="line">127.0.0.1:6667&gt;</span><br></pre></td></tr></table></figure>
<p>1、可以看出6666端口的redis在集群中的位置为master，并且6667,6668,6669三个端口的redis为slave节点。复合我们搭建的期望。<br>2、在master节点设置的say字符串在从节点可以去到，说明数据复制是成功的。<br>3、在slave节点写数据时报错READONLY You can’t write against a read only slave.因为我们配置了<em>slave-read-only yes</em> 设置slave节点只允许读，不允许写。</p>
<p>在看下在sentinel节点输出的集群信息:</p>
<h4 id="master节点信息："><a href="#master节点信息：" class="headerlink" title="master节点信息："></a>master节点信息：</h4><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">127.0.0.1:6670&gt; sentinel masters</span><br><span class="line">1)  1) &quot;name&quot;</span><br><span class="line">    2) &quot;mymaster&quot;</span><br><span class="line">    3) &quot;ip&quot;</span><br><span class="line">    4) &quot;127.0.0.1&quot;</span><br><span class="line">    5) &quot;port&quot;</span><br><span class="line">    6) &quot;6666&quot;</span><br><span class="line">    7) &quot;runid&quot;</span><br><span class="line">    8) &quot;3038a84c9d30d8c8a210e130c730f10fe923af01&quot;</span><br><span class="line">    9) &quot;flags&quot;</span><br><span class="line">   10) &quot;master&quot;</span><br><span class="line">   11) &quot;link-pending-commands&quot;</span><br><span class="line">   12) &quot;0&quot;</span><br><span class="line">   13) &quot;link-refcount&quot;</span><br><span class="line">   14) &quot;1&quot;</span><br><span class="line">   15) &quot;last-ping-sent&quot;</span><br><span class="line">   16) &quot;0&quot;</span><br><span class="line">   17) &quot;last-ok-ping-reply&quot;</span><br><span class="line">   18) &quot;126&quot;</span><br><span class="line">   19) &quot;last-ping-reply&quot;</span><br><span class="line">   20) &quot;126&quot;</span><br><span class="line">   21) &quot;down-after-milliseconds&quot;</span><br><span class="line">   22) &quot;30000&quot;</span><br><span class="line">   23) &quot;info-refresh&quot;</span><br><span class="line">   24) &quot;4916&quot;</span><br><span class="line">   25) &quot;role-reported&quot;</span><br><span class="line">   26) &quot;master&quot;</span><br><span class="line">   27) &quot;role-reported-time&quot;</span><br><span class="line">   28) &quot;45780434&quot;</span><br><span class="line">   29) &quot;config-epoch&quot;</span><br><span class="line">   30) &quot;0&quot;</span><br><span class="line">   31) &quot;num-slaves&quot;</span><br><span class="line">   32) &quot;3&quot;</span><br><span class="line">   33) &quot;num-other-sentinels&quot;</span><br><span class="line">   34) &quot;1&quot;</span><br><span class="line">   35) &quot;quorum&quot;</span><br><span class="line">   36) &quot;2&quot;</span><br><span class="line">   37) &quot;failover-timeout&quot;</span><br><span class="line">   38) &quot;180000&quot;</span><br><span class="line">   39) &quot;parallel-syncs&quot;</span><br><span class="line">   40) &quot;1&quot;</span><br></pre></td></tr></table></figure>
<h4 id="slave节点信息"><a href="#slave节点信息" class="headerlink" title="slave节点信息"></a>slave节点信息</h4><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">127.0.0.1:6670&gt; sentinel slaves mymaster</span><br><span class="line">1)  1) &quot;name&quot;</span><br><span class="line">    2) &quot;127.0.0.1:6668&quot;</span><br><span class="line">    3) &quot;ip&quot;</span><br><span class="line">    4) &quot;127.0.0.1&quot;</span><br><span class="line">    5) &quot;port&quot;</span><br><span class="line">    6) &quot;6668&quot;</span><br><span class="line">    7) &quot;runid&quot;</span><br><span class="line">    8) &quot;178be634dadcb3ecdaabae4ec11b4e67d1b64438&quot;</span><br><span class="line">    9) &quot;flags&quot;</span><br><span class="line">   10) &quot;slave&quot;</span><br><span class="line">   11) &quot;link-pending-commands&quot;</span><br><span class="line">   12) &quot;0&quot;</span><br><span class="line">   13) &quot;link-refcount&quot;</span><br><span class="line">   14) &quot;1&quot;</span><br><span class="line">   15) &quot;last-ping-sent&quot;</span><br><span class="line">   16) &quot;0&quot;</span><br><span class="line">   17) &quot;last-ok-ping-reply&quot;</span><br><span class="line">   18) &quot;489&quot;</span><br><span class="line">   19) &quot;last-ping-reply&quot;</span><br><span class="line">   20) &quot;489&quot;</span><br><span class="line">   21) &quot;down-after-milliseconds&quot;</span><br><span class="line">   22) &quot;30000&quot;</span><br><span class="line">   23) &quot;info-refresh&quot;</span><br><span class="line">   24) &quot;792&quot;</span><br><span class="line">   25) &quot;role-reported&quot;</span><br><span class="line">   26) &quot;slave&quot;</span><br><span class="line">   27) &quot;role-reported-time&quot;</span><br><span class="line">   28) &quot;45856556&quot;</span><br><span class="line">   29) &quot;master-link-down-time&quot;</span><br><span class="line">   30) &quot;0&quot;</span><br><span class="line">   31) &quot;master-link-status&quot;</span><br><span class="line">   32) &quot;ok&quot;</span><br><span class="line">   33) &quot;master-host&quot;</span><br><span class="line">   34) &quot;127.0.0.1&quot;</span><br><span class="line">   35) &quot;master-port&quot;</span><br><span class="line">   36) &quot;6666&quot;</span><br><span class="line">   37) &quot;slave-priority&quot;</span><br><span class="line">   38) &quot;100&quot;</span><br><span class="line">   39) &quot;slave-repl-offset&quot;</span><br><span class="line">   40) &quot;5914039&quot;</span><br><span class="line">2)  1) &quot;name&quot;</span><br><span class="line">    2) &quot;127.0.0.1:6667&quot;</span><br><span class="line">    3) &quot;ip&quot;</span><br><span class="line">    4) &quot;127.0.0.1&quot;</span><br><span class="line">    5) &quot;port&quot;</span><br><span class="line">    6) &quot;6667&quot;</span><br><span class="line">    7) &quot;runid&quot;</span><br><span class="line">    8) &quot;26181877816afa0987a0c59c7b25d6fbc0a5e111&quot;</span><br><span class="line">    9) &quot;flags&quot;</span><br><span class="line">   10) &quot;slave&quot;</span><br><span class="line">   11) &quot;link-pending-commands&quot;</span><br><span class="line">   12) &quot;0&quot;</span><br><span class="line">   13) &quot;link-refcount&quot;</span><br><span class="line">   14) &quot;1&quot;</span><br><span class="line">   15) &quot;last-ping-sent&quot;</span><br><span class="line">   16) &quot;0&quot;</span><br><span class="line">   17) &quot;last-ok-ping-reply&quot;</span><br><span class="line">   18) &quot;489&quot;</span><br><span class="line">   19) &quot;last-ping-reply&quot;</span><br><span class="line">   20) &quot;489&quot;</span><br><span class="line">   21) &quot;down-after-milliseconds&quot;</span><br><span class="line">   22) &quot;30000&quot;</span><br><span class="line">   23) &quot;info-refresh&quot;</span><br><span class="line">   24) &quot;792&quot;</span><br><span class="line">   25) &quot;role-reported&quot;</span><br><span class="line">   26) &quot;slave&quot;</span><br><span class="line">   27) &quot;role-reported-time&quot;</span><br><span class="line">   28) &quot;45856557&quot;</span><br><span class="line">   29) &quot;master-link-down-time&quot;</span><br><span class="line">   30) &quot;0&quot;</span><br><span class="line">   31) &quot;master-link-status&quot;</span><br><span class="line">   32) &quot;ok&quot;</span><br><span class="line">   33) &quot;master-host&quot;</span><br><span class="line">   34) &quot;127.0.0.1&quot;</span><br><span class="line">   35) &quot;master-port&quot;</span><br><span class="line">   36) &quot;6666&quot;</span><br><span class="line">   37) &quot;slave-priority&quot;</span><br><span class="line">   38) &quot;100&quot;</span><br><span class="line">   39) &quot;slave-repl-offset&quot;</span><br><span class="line">   40) &quot;5914039&quot;</span><br><span class="line">3)  1) &quot;name&quot;</span><br><span class="line">    2) &quot;127.0.0.1:6669&quot;</span><br><span class="line">    3) &quot;ip&quot;</span><br><span class="line">    4) &quot;127.0.0.1&quot;</span><br><span class="line">    5) &quot;port&quot;</span><br><span class="line">    6) &quot;6669&quot;</span><br><span class="line">    7) &quot;runid&quot;</span><br><span class="line">    8) &quot;d771c236b81ab96914e43fa601d2f5930965d6eb&quot;</span><br><span class="line">    9) &quot;flags&quot;</span><br><span class="line">   10) &quot;slave&quot;</span><br><span class="line">   11) &quot;link-pending-commands&quot;</span><br><span class="line">   12) &quot;0&quot;</span><br><span class="line">   13) &quot;link-refcount&quot;</span><br><span class="line">   14) &quot;1&quot;</span><br><span class="line">   15) &quot;last-ping-sent&quot;</span><br><span class="line">   16) &quot;0&quot;</span><br><span class="line">   17) &quot;last-ok-ping-reply&quot;</span><br><span class="line">   18) &quot;489&quot;</span><br><span class="line">   19) &quot;last-ping-reply&quot;</span><br><span class="line">   20) &quot;489&quot;</span><br><span class="line">   21) &quot;down-after-milliseconds&quot;</span><br><span class="line">   22) &quot;30000&quot;</span><br><span class="line">   23) &quot;info-refresh&quot;</span><br><span class="line">   24) &quot;792&quot;</span><br><span class="line">   25) &quot;role-reported&quot;</span><br><span class="line">   26) &quot;slave&quot;</span><br><span class="line">   27) &quot;role-reported-time&quot;</span><br><span class="line">   28) &quot;45856554&quot;</span><br><span class="line">   29) &quot;master-link-down-time&quot;</span><br><span class="line">   30) &quot;0&quot;</span><br><span class="line">   31) &quot;master-link-status&quot;</span><br><span class="line">   32) &quot;ok&quot;</span><br><span class="line">   33) &quot;master-host&quot;</span><br><span class="line">   34) &quot;127.0.0.1&quot;</span><br><span class="line">   35) &quot;master-port&quot;</span><br><span class="line">   36) &quot;6666&quot;</span><br><span class="line">   37) &quot;slave-priority&quot;</span><br><span class="line">   38) &quot;100&quot;</span><br><span class="line">   39) &quot;slave-repl-offset&quot;</span><br><span class="line">   40) &quot;5914039&quot;</span><br><span class="line">127.0.0.1:6670&gt;</span><br></pre></td></tr></table></figure>
<h3 id="2、自动故障切换"><a href="#2、自动故障切换" class="headerlink" title="2、自动故障切换"></a>2、自动故障切换</h3><p>当我们的master节点发生故障宕机时，sentinel会为我们自动选取master节点，当故障的前master节点恢复后，会自动加入到集群中来<br><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">127.0.0.1:6671&gt; sentinel masters</span><br><span class="line">1)  1) &quot;name&quot;</span><br><span class="line">    2) &quot;mymaster&quot;</span><br><span class="line">    3) &quot;ip&quot;</span><br><span class="line">    4) &quot;127.0.0.1&quot;</span><br><span class="line">    5) &quot;port&quot;</span><br><span class="line">    6) &quot;6668&quot;</span><br><span class="line">    7) &quot;runid&quot;</span><br><span class="line">    8) &quot;178be634dadcb3ecdaabae4ec11b4e67d1b64438&quot;</span><br><span class="line">    9) &quot;flags&quot;</span><br><span class="line">   10) &quot;master&quot;</span><br><span class="line">   11) &quot;link-pending-commands&quot;</span><br><span class="line">   12) &quot;0&quot;</span><br><span class="line">   13) &quot;link-refcount&quot;</span><br><span class="line">   14) &quot;1&quot;</span><br><span class="line">   15) &quot;last-ping-sent&quot;</span><br><span class="line">   16) &quot;0&quot;</span><br><span class="line">   17) &quot;last-ok-ping-reply&quot;</span><br><span class="line">   18) &quot;660&quot;</span><br><span class="line">   19) &quot;last-ping-reply&quot;</span><br><span class="line">   20) &quot;660&quot;</span><br><span class="line">   21) &quot;down-after-milliseconds&quot;</span><br><span class="line">   22) &quot;30000&quot;</span><br><span class="line">   23) &quot;info-refresh&quot;</span><br><span class="line">   24) &quot;2137&quot;</span><br><span class="line">   25) &quot;role-reported&quot;</span><br><span class="line">   26) &quot;master&quot;</span><br><span class="line">   27) &quot;role-reported-time&quot;</span><br><span class="line">   28) &quot;102877&quot;</span><br><span class="line">   29) &quot;config-epoch&quot;</span><br><span class="line">   30) &quot;1&quot;</span><br><span class="line">   31) &quot;num-slaves&quot;</span><br><span class="line">   32) &quot;3&quot;</span><br><span class="line">   33) &quot;num-other-sentinels&quot;</span><br><span class="line">   34) &quot;1&quot;</span><br><span class="line">   35) &quot;quorum&quot;</span><br><span class="line">   36) &quot;2&quot;</span><br><span class="line">   37) &quot;failover-timeout&quot;</span><br><span class="line">   38) &quot;180000&quot;</span><br><span class="line">   39) &quot;parallel-syncs&quot;</span><br><span class="line">   40) &quot;1&quot;</span><br><span class="line">127.0.0.1:6671&gt;</span><br></pre></td></tr></table></figure></p>
<p>我们看到master节点由6666端口的redis变为端口为6668端口的redis</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">127.0.0.1:6671&gt; sentinel slaves mymaster</span><br><span class="line">1)  1) &quot;name&quot;</span><br><span class="line">    2) &quot;127.0.0.1:6669&quot;</span><br><span class="line">    3) &quot;ip&quot;</span><br><span class="line">    4) &quot;127.0.0.1&quot;</span><br><span class="line">    5) &quot;port&quot;</span><br><span class="line">    6) &quot;6669&quot;</span><br><span class="line">    7) &quot;runid&quot;</span><br><span class="line">    8) &quot;d771c236b81ab96914e43fa601d2f5930965d6eb&quot;</span><br><span class="line">    9) &quot;flags&quot;</span><br><span class="line">   10) &quot;slave&quot;</span><br><span class="line">   11) &quot;link-pending-commands&quot;</span><br><span class="line">   12) &quot;0&quot;</span><br><span class="line">   13) &quot;link-refcount&quot;</span><br><span class="line">   14) &quot;1&quot;</span><br><span class="line">   15) &quot;last-ping-sent&quot;</span><br><span class="line">   16) &quot;0&quot;</span><br><span class="line">   17) &quot;last-ok-ping-reply&quot;</span><br><span class="line">   18) &quot;993&quot;</span><br><span class="line">   19) &quot;last-ping-reply&quot;</span><br><span class="line">   20) &quot;993&quot;</span><br><span class="line">   21) &quot;down-after-milliseconds&quot;</span><br><span class="line">   22) &quot;30000&quot;</span><br><span class="line">   23) &quot;info-refresh&quot;</span><br><span class="line">   24) &quot;8839&quot;</span><br><span class="line">   25) &quot;role-reported&quot;</span><br><span class="line">   26) &quot;slave&quot;</span><br><span class="line">   27) &quot;role-reported-time&quot;</span><br><span class="line">   28) &quot;161485&quot;</span><br><span class="line">   29) &quot;master-link-down-time&quot;</span><br><span class="line">   30) &quot;0&quot;</span><br><span class="line">   31) &quot;master-link-status&quot;</span><br><span class="line">   32) &quot;ok&quot;</span><br><span class="line">   33) &quot;master-host&quot;</span><br><span class="line">   34) &quot;127.0.0.1&quot;</span><br><span class="line">   35) &quot;master-port&quot;</span><br><span class="line">   36) &quot;6668&quot;</span><br><span class="line">   37) &quot;slave-priority&quot;</span><br><span class="line">   38) &quot;100&quot;</span><br><span class="line">   39) &quot;slave-repl-offset&quot;</span><br><span class="line">   40) &quot;5943301&quot;</span><br><span class="line">2)  1) &quot;name&quot;</span><br><span class="line">    2) &quot;127.0.0.1:6666&quot;</span><br><span class="line">    3) &quot;ip&quot;</span><br><span class="line">    4) &quot;127.0.0.1&quot;</span><br><span class="line">    5) &quot;port&quot;</span><br><span class="line">    6) &quot;6666&quot;</span><br><span class="line">    7) &quot;runid&quot;</span><br><span class="line">    8) &quot;&quot;</span><br><span class="line">    9) &quot;flags&quot;</span><br><span class="line">   10) &quot;s_down,slave,disconnected&quot;</span><br><span class="line">   11) &quot;link-pending-commands&quot;</span><br><span class="line">   12) &quot;2&quot;</span><br><span class="line">   13) &quot;link-refcount&quot;</span><br><span class="line">   14) &quot;1&quot;</span><br><span class="line">   15) &quot;last-ping-sent&quot;</span><br><span class="line">   16) &quot;161485&quot;</span><br><span class="line">   17) &quot;last-ok-ping-reply&quot;</span><br><span class="line">   18) &quot;161485&quot;</span><br><span class="line">   19) &quot;last-ping-reply&quot;</span><br><span class="line">   20) &quot;161485&quot;</span><br><span class="line">   21) &quot;s-down-time&quot;</span><br><span class="line">   22) &quot;131453&quot;</span><br><span class="line">   23) &quot;down-after-milliseconds&quot;</span><br><span class="line">   24) &quot;30000&quot;</span><br><span class="line">   25) &quot;info-refresh&quot;</span><br><span class="line">   26) &quot;1513731360281&quot;</span><br><span class="line">   27) &quot;role-reported&quot;</span><br><span class="line">   28) &quot;slave&quot;</span><br><span class="line">   29) &quot;role-reported-time&quot;</span><br><span class="line">   30) &quot;161485&quot;</span><br><span class="line">   31) &quot;master-link-down-time&quot;</span><br><span class="line">   32) &quot;0&quot;</span><br><span class="line">   33) &quot;master-link-status&quot;</span><br><span class="line">   34) &quot;err&quot;</span><br><span class="line">   35) &quot;master-host&quot;</span><br><span class="line">   36) &quot;?&quot;</span><br><span class="line">   37) &quot;master-port&quot;</span><br><span class="line">   38) &quot;0&quot;</span><br><span class="line">   39) &quot;slave-priority&quot;</span><br><span class="line">   40) &quot;100&quot;</span><br><span class="line">   41) &quot;slave-repl-offset&quot;</span><br><span class="line">   42) &quot;0&quot;</span><br><span class="line">3)  1) &quot;name&quot;</span><br><span class="line">    2) &quot;127.0.0.1:6667&quot;</span><br><span class="line">    3) &quot;ip&quot;</span><br><span class="line">    4) &quot;127.0.0.1&quot;</span><br><span class="line">    5) &quot;port&quot;</span><br><span class="line">    6) &quot;6667&quot;</span><br><span class="line">    7) &quot;runid&quot;</span><br><span class="line">    8) &quot;26181877816afa0987a0c59c7b25d6fbc0a5e111&quot;</span><br><span class="line">    9) &quot;flags&quot;</span><br><span class="line">   10) &quot;slave&quot;</span><br><span class="line">   11) &quot;link-pending-commands&quot;</span><br><span class="line">   12) &quot;0&quot;</span><br><span class="line">   13) &quot;link-refcount&quot;</span><br><span class="line">   14) &quot;1&quot;</span><br><span class="line">   15) &quot;last-ping-sent&quot;</span><br><span class="line">   16) &quot;0&quot;</span><br><span class="line">   17) &quot;last-ok-ping-reply&quot;</span><br><span class="line">   18) &quot;182&quot;</span><br><span class="line">   19) &quot;last-ping-reply&quot;</span><br><span class="line">   20) &quot;182&quot;</span><br><span class="line">   21) &quot;down-after-milliseconds&quot;</span><br><span class="line">   22) &quot;30000&quot;</span><br><span class="line">   23) &quot;info-refresh&quot;</span><br><span class="line">   24) &quot;9990&quot;</span><br><span class="line">   25) &quot;role-reported&quot;</span><br><span class="line">   26) &quot;slave&quot;</span><br><span class="line">   27) &quot;role-reported-time&quot;</span><br><span class="line">   28) &quot;161485&quot;</span><br><span class="line">   29) &quot;master-link-down-time&quot;</span><br><span class="line">   30) &quot;0&quot;</span><br><span class="line">   31) &quot;master-link-status&quot;</span><br><span class="line">   32) &quot;ok&quot;</span><br><span class="line">   33) &quot;master-host&quot;</span><br><span class="line">   34) &quot;127.0.0.1&quot;</span><br><span class="line">   35) &quot;master-port&quot;</span><br><span class="line">   36) &quot;6668&quot;</span><br><span class="line">   37) &quot;slave-priority&quot;</span><br><span class="line">   38) &quot;100&quot;</span><br><span class="line">   39) &quot;slave-repl-offset&quot;</span><br><span class="line">   40) &quot;5943037&quot;</span><br><span class="line">127.0.0.1:6671&gt;</span><br></pre></td></tr></table></figure>
<p>同样，我们看到原来的master节点6666恢复后变成了一个slave节点。</p>
<p>所以，sentinel模式的redis集群，完美的实现了我们主从复制，以及自动故障转移的功能。</p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>


    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/blog/tags/redis/" rel="tag"># redis</a>
          
            <a href="/blog/tags/redis集群/" rel="tag"># redis集群</a>
          
        </div>
      

      
        
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/blog/2017/12/16/Mongo查询分析以及索引规则二/" rel="next" title="Mongo查询分析以及索引规则二">
                <i class="fa fa-chevron-left"></i> Mongo查询分析以及索引规则二
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/blog/2017/12/18/redis集群模式搭建/" rel="prev" title="redis集群模式搭建">
                redis集群模式搭建 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>

          
          </div>
          


          
  <div class="comments" id="comments">
    
      <div id="lv-container" data-id="city" data-uid="MTAyMC8zNjY5NS8xMzIzMA=="></div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/blog/images/head.jpg"
               alt="Fang ShuHao" />
          <p class="site-author-name" itemprop="name">Fang ShuHao</p>
           
              <p class="site-description motion-element" itemprop="description"></p>
          
        </div>
        <nav class="site-state motion-element">
        
          
            <div class="site-state-item site-state-posts">
              <a href="/blog/archives">
                <span class="site-state-item-count">135</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-categories">
              <a href="/blog/categories">
                <span class="site-state-item-count">35</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/blog/tags">
                <span class="site-state-item-count">93</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#sentinel-哨兵模式的搭建"><span class="nav-number">1.</span> <span class="nav-text">sentinel 哨兵模式的搭建</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1、安装redis"><span class="nav-number">1.1.</span> <span class="nav-text">1、安装redis</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2、新建目录"><span class="nav-number">1.2.</span> <span class="nav-text">2、新建目录</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3、配置"><span class="nav-number">1.3.</span> <span class="nav-text">3、配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#复制配置文件到服务节点以及哨兵节点"><span class="nav-number">1.4.</span> <span class="nav-text">复制配置文件到服务节点以及哨兵节点</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#修改master目录-redis-conf"><span class="nav-number">1.5.</span> <span class="nav-text">修改master目录 redis.conf</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#修改slave-1目录-redis-conf"><span class="nav-number">1.6.</span> <span class="nav-text">修改slave_1目录 redis.conf</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#修改slave-2目录-redis-conf"><span class="nav-number">1.7.</span> <span class="nav-text">修改slave_2目录 redis.conf</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#修改slave-3目录-redis-conf"><span class="nav-number">1.8.</span> <span class="nav-text">修改slave_3目录 redis.conf</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#修改sentinel-1目录sentinel-conf"><span class="nav-number">1.9.</span> <span class="nav-text">修改sentinel_1目录sentinel.conf</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#修改sentinel-2目录sentinel-conf"><span class="nav-number">1.10.</span> <span class="nav-text">修改sentinel_2目录sentinel.conf</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4、启动"><span class="nav-number">1.11.</span> <span class="nav-text">4、启动</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#关于sentinel模式的几个命令"><span class="nav-number">1.12.</span> <span class="nav-text">关于sentinel模式的几个命令</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#验证哨兵模式功能"><span class="nav-number">2.</span> <span class="nav-text">验证哨兵模式功能</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1、主从复制"><span class="nav-number">2.1.</span> <span class="nav-text">1、主从复制</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#master节点信息："><span class="nav-number">2.1.1.</span> <span class="nav-text">master节点信息：</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#slave节点信息"><span class="nav-number">2.1.2.</span> <span class="nav-text">slave节点信息</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2、自动故障切换"><span class="nav-number">2.2.</span> <span class="nav-text">2、自动故障切换</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Fang ShuHao</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    
    
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  




  
  <script type="text/javascript" src="/blog/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/blog/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/blog/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=5.1.0"></script>



  
  

  
  <script type="text/javascript" src="/blog/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/blog/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=5.1.0"></script>



  



  




	





  





  





  
    <script type="text/javascript">
      (function(d, s) {
        var j, e = d.getElementsByTagName(s)[0];
        if (typeof LivereTower === 'function') { return; }
        j = d.createElement(s);
        j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
        j.async = true;
        e.parentNode.insertBefore(j, e);
      })(document, 'script');
    </script>
  



  
  

  

  

  

  


  

</body>
</html>
